import 'package:dio/dio.dart';

class CourseAPI {
  final Dio? _dio;
  CourseAPI(this._dio);

  // 课程列表
  Future<dynamic> courseList({ String spaceKeys = '999' }) async{
    // Response? res = await _dio?.get('https://www.dmoe.cc/random.php?return=json',
    Response? res = await _dio?.get('/course.json',
      queryParameters: {
        'spaceKeys': spaceKeys
      }
    );
    return res?.data['content'];
    
  }

  // 课程详情
  Future<dynamic> courseDetail({ required int id }) async{
    // Response? res = await _dio?.get('https://www.dmoe.cc/random.php?return=json',
    Response? res = await _dio?.get('/course.json',
      queryParameters: {
        'courseId': id
      }
    );
    return res?.data['content'];
    
  }

  // 课程章节
  Future<dynamic> courseSection({ required int id }) async{
    Response? res = await _dio?.get('/courseSection.json',
    // Response? res = await _dio?.get('/course.json',
      queryParameters: {
        'courseId': id
      }
    );
    return res?.data['content'];
    
  }
}